package com.weixing.mall.provider.controller.admin;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.annotation.NoRepeatSubmit;
import com.weixing.mall.provider.model.dto.CategoryBrandDelDto;
import com.weixing.mall.provider.model.dto.CategoryBrandListDto;
import com.weixing.mall.provider.model.query.CategoryBrandQuery;
import com.weixing.mall.provider.service.ICategoryBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CategoryBrandController
 * @Description TODO <br/>
 * @Author gjq
 * @Modified By:
 * @Date 2019/8/6
 * @Version 1.0
 **/
@RestController
@RequestMapping("categoryBrand")
@Api(value = "商品类目品牌关联APi", tags = "商品类目品牌关联")
public class CategoryBrandController {

    @Autowired
    private ICategoryBrandService categoryBrandService;

    @ApiOperation(value = "根据条件加载商品类目参数")
    @GetMapping("getList")
    public Result list(CategoryBrandQuery categoryBrandQuery) {
        return ResultUtil.success(categoryBrandService.selectList(categoryBrandQuery));
    }

    @ApiOperation(value = "保存商品类目品牌关联")
    @PostMapping("save")
    @NoRepeatSubmit
    public Result save(@Validated CategoryBrandListDto categoryBrandListDto) {
        categoryBrandService.save(categoryBrandListDto);
        return ResultUtil.success();
    }

    @ApiOperation(value = "批量删除商品类目品牌关联）")
    @PostMapping("delAll")
    public Result delAll(CategoryBrandDelDto categoryBrandDelDto) {
        categoryBrandService.deleteByIds(categoryBrandDelDto);
        return ResultUtil.success();
    }
}
